﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Editor.Properties;

namespace Editor
{
    public partial class NewString : Form
    {
        internal string Key { get; private set; }
        internal string Value { get; private set; }

        public NewString()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtKey.Text.Trim() == string.Empty)
            {
                errorProvider1.SetError(txtKey, Resources.CannotEmpty);
                return;
            }
            else if (Main.Current.IsKeyExist(txtKey.Text))
            {
                errorProvider1.SetError(txtKey, string.Format(Resources.KeyExist, txtKey.Text));
                return;
            }
            else
            {
                errorProvider1.SetError(txtKey, string.Empty);
            }

            Key = txtKey.Text;
            Value = txtValue.Text;

            DialogResult = DialogResult.OK;
        }
    }
}
